{extend name="public:index"/}
{block name="title"}{:sysconf('title')}{/block}
{block name="content"}
<section class="whtop">
    <div class="top">
        <p class="p1"><a href="javascript:history.back(-1)"></a></p>
        <p class="p2">打卡签到</p>
        <p class="p3"></p>
    </div>
</section>
<section style="height:2rem;"></section>

<section class="jifenbox">

    {if condition="$sign"}
    <p class="p1 pp2">
    	<img src="__INDEX__/images/qiandao.gif" alt="">
    </p>
    <p class="pp1" style="text-align:center;">已签到</p>
    {else/}
    <p class="p1 pp2">
    	<img src="__INDEX__/images/qiandao.png" alt="">
    </p>
    <p class="pp1" style="text-align:center;">点击签到</p>
    {/if}
    <div class="daka">
        <p class="p1"><em>{$day}</em>累计打卡</p>
        <p class="p2"><em>{$point}</em>累计积分</p>
    </div>
</section>
<script>
    $(".jifenbox .p1").click(function () {
        $.ajax({
            url: "{:url('Sign/sign')}",
            type: "POST",
            dataType: "JSON",
            success: function(data) {
            	console.log(data)
                if (data.code == 0) {
                    layer.msg(data.msg,{'icon':6,time:1000});
                    $('.daka .p1 em').html(data.data.day)
                    var leij = $('.daka .p2 em').html()
                    $('.daka .p2 em').html(parseInt(leij)+parseInt(data.data.point))
                    $('.pp2 img').attr('src','__INDEX__/images/qiandao.gif');
                    $('.pp1').html('已签到')
                } else {
                    layer.msg(data.msg,{'icon':5});
                }
            },
            error: function(){
                layer.msg("网络延迟，发送失败",{icon:5});
            }
        });
    })
</script>
{/block}